import api from "@/utils/api";

// 获取客户剩余面单统计
export const getCustomerWaybillStats = async (customerId) => {
  try {
    const response = await api.get(`/waybill-stats/customer/${customerId}`);
    return response.data;
  } catch (error) {
    console.error("获取客户面单统计失败:", error);
    return { totalRecharged: 0, totalUsed: 0, remaining: 0 };
  }
};

// 获取店铺快递公司面单统计
export const getShopExpressStats = async (shopId) => {
  try {
    const response = await api.get(`/waybill-stats/shop/${shopId}`);
    return response.data;
  } catch (error) {
    console.error("获取店铺面单统计失败:", error);
    return {};
  }
};

// 批量获取客户面单统计
export const getBatchCustomerWaybillStats = async (customerIds) => {
  try {
    const response = await api.post("/waybill-stats/batch-customers", {
      customerIds,
    });
    return response.data;
  } catch (error) {
    console.error("批量获取客户面单统计失败:", error);
    return {};
  }
};

// 批量获取店铺面单统计
export const getBatchShopWaybillStats = async (shopIds) => {
  try {
    const response = await api.post("/waybill-stats/batch-shops", { shopIds });
    return response.data;
  } catch (error) {
    console.error("批量获取店铺面单统计失败:", error);
    return {};
  }
};
